package com.lijian.study.neo4j.entity;

import java.util.Objects;
import java.util.Set;

import org.springframework.data.neo4j.core.schema.GeneratedValue;
import org.springframework.data.neo4j.core.schema.Id;
import org.springframework.data.neo4j.core.schema.Node;
import org.springframework.data.neo4j.core.schema.Property;
import org.springframework.data.neo4j.core.schema.Relationship;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

/**
 * 创作一个对应 Person 实体对象 -> 对应我们 Neo4j数据库中的 Node 对象
 */
@Setter
@Getter
@Node("Person")
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class Person {

    @Id
    @GeneratedValue()
    private Long id;

    @Property
    private String name;

    @Property
    private int age;

    @Relationship(type = "KNOWS", direction = Relationship.Direction.OUTGOING)
    private Set<Knows> knows;

    @Override
    public int hashCode() {
        return Objects.hash(id, name, age); // 不包括knows集合
    }
}
